{layout name="passport:layout" /}
<div class="tipbox tipbox-message">
    <span class="fn-f14 fn-fb red">友情提示：</span><br />
    1、先打开微信官方小程序平台（<a href="https://mp.weixin.qq.com" target="_blank">https://mp.weixin.qq.com</a>）创建和认证您的小程序。<br />
    2、如果授权过期,请用小程序管理员微信重新扫码授权。<a href="{:url('system/passport.setting/pushAuth',['id' => $member_miniapp_id,'types'=>'program'])}" type="button" class="button button-mini button-green" /> <i class="iconfont icon-erweima1"></i>重新授权</a><br />
    3、小程序开通顺序是:<span class="red">创建小程序 -> 提交代码 -> 提交审核 -> 提交发布 -> 开通小程序</span>。
</div>
<ul class="crumbs">
    <li class="pass fn-cp" id="create">1、创建小程序<em></em><i></i></li>
    <li class="{if $code.is_commit==0}off{/if}{if $code.is_commit >=1}pass{/if} fn-cp" id="domain">2、设置域名<em></em><i></i></li>
    <li class="{if $code.is_commit==1}off{/if}{if $code.is_commit >=2}pass{/if} fn-cp" id="addcode">3、上传代码<em></em><i></i></li>
    <li class="{if $code.is_commit==2}off{/if}{if $code.is_commit >=3}pass{/if} fn-cp" id="addpass">4、提交审核<em></em><i></i></li>
    <li class="{if $code.is_commit==3}off{/if}{if $code.is_commit >=4}pass{/if} fn-cp" id="sendapp">5、发布小程序<em></em><i></i></li>
    <li class="{if $code.is_commit==4}off{/if}{if $code.is_commit >=5}pass{/if} fn-cp" id="passapp">6、开通<em></em><i></i></li>
</ul>
<div class="setting {if $code.is_commit==1}isnow{/if} addcode fn-hide">
    <div class="tipbox">
        <span class="fn-f14 fn-fb green">注意：</span>提交小程序代码前,请先确认已经在微信平台中创建了小程序信息。<br />
    </div>
</div>
<div class="setting {if $code.is_commit==2}isnow{/if} addpass fn-hide">
    <div class="tipbox">
        <span class="fn-f14 fn-fb green">注意：</span>提交审核小程序前,必须先上传代码。<br />
    </div>
</div>
<div class="setting {if $code.is_commit==3}isnow{/if} sendapp fn-hide">
    <div class="tipbox">
        <span class="fn-f14 fn-fb green">注意：</span>发布的小程序,必须现实状态是审核通过的。<br />
    </div>
</div>
<table class="pure-table">
    <tr><td class="w120 fn-tar">APPID：</td><td>{$member_miniapp.miniapp_appid}</td></tr>
    <tr class="setting create fn-hide">
        <td class="w120 fn-tar">创建小程序：</td><td>
            <a href="https://mp.weixin.qq.com" target="_blank" class="button button-violet" /><i class="iconfont icon-add_icon"></i>去微信创建小程序信息</a>
        </td>
    </tr>
    {if $code.is_commit <= 2 || $code.is_commit == 4 || $auditid.status == 0 || $auditid.status == 1}
        <tr class="setting domain {if $code.is_commit==0}isnow{/if} fn-hide">
            <td class="w120 fn-tar">设置域名：</td><td><button type="button" class="button button-violet getdomain" /><i class="iconfont icon-lianjie"></i>绑定API域名</button></td>
        </tr>
        <tr class="setting {if $code.is_commit==1}isnow{/if} addcode fn-hide">
            <td class="w120 fn-tar">上传代码：</td><td><button type="button" class="button button-yellow getupcode" /><i class="iconfont icon-xiangshang5"></i>{$update_var?'立即升级':'上传代码'}</button></td>
        </tr>
    {/if}
    {if $code.is_commit == 2}
    <tr class="setting {if $code.is_commit==2}isnow{/if} addpass fn-hide">
        <td class="w120 fn-tar">提交审核：</td><td>
            <button type="button" class="button button-violet win" id="{$member_miniapp_id}" url="{:url('system/passport.miniapp/submitPass')}"/><i class="iconfont icon-add_icon"></i>提交审核</button>
        </td>
    </tr>
    {/if}
    {if $auditid.status == 0}
    <tr class="setting {if $code.is_commit==3}isnow{/if} sendapp fn-hide">
        <td class="w120 fn-tar">发布小程序：</td><td>
            <button type="button" class="button button-violet getsendapp" /><i class="iconfont icon-affirm_icon"></i>发布小程序</button>
        </td>
    </tr>
    {/if}
    <tr>
        <td class="w120 fn-tar">状态</td><td>
            {switch $code['is_commit']}
            {case 1}<span class="badge bg-blue">已设置域名</span>{/case}
            {case 2}<span class="badge bg-red">等待提交审核</span>{/case}
            {case 3}
                {switch $auditid.status}
                    {case 0}<span class="badge bg-green">审核通过</span>{/case}
                    {case 1}<span class="badge bg-red">审核失败</span>{/case}
                    {case 2}<span class="badge bg-blue">审核中</span>{/case}
                    {default /}<span class="badge bg-yellow">未提交</span>
                {/switch} 
            {/case}
            {case 4}<span class="badge bg-green">已开通</span>{/case}
            {default /}<span class="badge">没有状态</span>
            {/switch} 
        </td>
    </tr>
    {if !empty($auditid) && $auditid.status == 2}
    <tr class="setting {if $code.is_commit==3}isnow{/if} sendapp fn-hide">
        <td class="w120 fn-tar">撤回审核：</td><td>
            <button type="button" class="button restpass" /><i class="iconfont icon-reduce_icon"></i>撤回审核</button>
            <span>单个帐号每天审核撤回次数最多不超过1次，一个月不超过10次</span>
        </td>
    </tr>
    {/if}
    {if !empty($auditid) && $auditid.status == 1}
        <tr><td class="w120 fn-tar">审核失败原因</td><td>{$auditid.reason}</td></tr>
    {/if}
    {if $code['is_commit'] >= 2}
    <tr>
        <td class="w120 fn-tar">体验码：</td><td><button type="button" class="button getqrcode" /> <i class="iconfont icon-erweima1"></i>获取体验二维码</button></td>
    </tr>
    {if $code['trial_qrcode']}<tr><td></td><td><img src="{$code['trial_qrcode']}" class="w200"></td></tr>{/if}
    {/if}
</table>
<script type="text/javascript">
Do('base', 'layer', 'form',function () {
    $('.isnow').show();
    $('.crumbs >li ').click(function(){
        var id = $(this).attr('id');
        $('.setting').hide();
        $('.'+id).show();
    })
    $('.getdomain').click(function(){
        $.post("{:url('system/passport.miniapp/domain')}", {id:{$member_miniapp_id}},function(rel){msg(rel)});
    })
    $('.getqrcode').click(function(){
        $.post("{:url('system/passport.miniapp/getqrcode')}", {id:{$member_miniapp_id}},function(rel){msg(rel)});
    })
    $('.getupcode').click(function(){
        $.post("{:url('system/passport.miniapp/upcode')}", {id:{$member_miniapp_id}},function(rel){msg(rel)});
    })
    $('.getsendapp').click(function(){
        $.post("{:url('system/passport.miniapp/sendapp')}", {id:{$member_miniapp_id}},function(rel){msg(rel)});
    })   
    //撤销审核
    $('.restpass').click(function(){
        $.post("{:url('system/passport.miniapp/restpass')}",{id:{$member_miniapp_id}},function(rel){msg(rel)});
    })
    $('.win').click(function(){
        var url = $(this).attr('url')+"?id="+$(this).attr('id');
        win_reload(url,['700px','480px']);
    })
})
function msg(rel){
    if(rel.code == 200){
        parent.layer.alert(rel.msg,function(index){
            parent.layer.close(index);
            window.location.reload();
        });
    }else{
        parent.layer.alert(rel.msg);
    }
}
</script>